import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '模板名称',
    align: "center",
    sorter: true,
    dataIndex: 'tmplateName'
  },
  {
    title: '消息类型',
    align: "center",
    sorter: true,
    dataIndex: 'msgtype_dictText'
  },
  {
    title: '标题',
    align: "center",
    sorter: true,
    dataIndex: 'title'
  },
  {
    title: '描述',
    align: "center",
    sorter: true,
    dataIndex: 'description',
  },
  {
    title: 'url',
    align: "center",
    dataIndex: 'url'
  },
  {
    title: '图片',
    align: "center",
    dataIndex: 'picurl',
    customRender: render.renderImage,
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'status',
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'Y'},{text:'否',value:'N'}]);
     },
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "模板名称",
    field: 'tmplateName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "消息类型",
    field: 'msgtype',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "wechat_msgtype"
    },
    //colProps: {span: 6},
  },
  {
    label: "标题",
    field: 'title',
    component: 'Input',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '模板名称',
    field: 'tmplateName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入模板名称!'},
             ];
    },
  },
  {
    label: '消息类型',
    field: 'msgtype',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "wechat_msgtype"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入消息类型!'},
             ];
    },
  },
  {
    label: '标题',
    field: 'title',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入标题!'},
             ];
    },
  },
  {
    label: '描述',
    field: 'description',
    component: 'JEditor',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入描述!'},
             ];
    },
  },
  {
    label: 'url',
    field: 'url',
    component: 'Input',
  },
  {
    label: '图片',
    field: 'picurl',
    component: 'JImageUpload',
    componentProps:{
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'JSwitch',
    componentProps:{
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  tmplateName: {title: '模板名称',order: 0,view: 'text', type: 'string',},
  msgtype: {title: '消息类型',order: 1,view: 'list', type: 'string',dictCode: 'wechat_msgtype',},
  title: {title: '标题',order: 2,view: 'text', type: 'string',},
  description: {title: '描述',order: 3,view: 'umeditor', type: 'string',},
  url: {title: 'url',order: 4,view: 'text', type: 'string',},
  picurl: {title: '图片',order: 5,view: 'image', type: 'string',},
  status: {title: '状态',order: 6,view: 'switch', type: 'string',},
};
